package cn.com.pansky.action.myaccount;

import cn.com.pansky.sdk.API;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import net.vsame.url2sql.action.CommonAction;

public class ReceiveTest extends CommonAction {
	public void receiveTest(){
		String STARYEAR = getParam("STARYEAR");//缴费起始年龄
		String ENDYEAR = getParam("ENDYEAR");//缴费终止年龄
		String AAA041 = getParam("AAA041");//年缴费金额
		String JCYLJ = getParam("JCYLJ");//基础养老金
		String AAA031 = getParam("AAA031");//年度定期利率
		
		if(Integer.parseInt(STARYEAR) < 16 || Integer.parseInt(STARYEAR) > 100){
			datas.put("isPass", false);
			datas.put("info", "起始年龄应在16~100岁之间");
			context.getDatas().put("result", datas);
			return;
		} 
		
		if(Integer.parseInt(ENDYEAR) < 60 || Integer.parseInt(ENDYEAR) > 120){
			datas.put("isPass", false);
			datas.put("info", "终止年龄应在60~120岁之间");
			context.getDatas().put("result", datas);
			return;
		} 
		
		JSONObject param = new JSONObject();
		param.put("AAA121", "QDYCS");
		param.put("STARYEAR", STARYEAR);
		param.put("ENDYEAR", ENDYEAR);
		param.put("AAA041", AAA041);
		param.put("JCYLJ", JCYLJ);
		param.put("AAA031", AAA031);
		param.put("AAC002", "1122"); // 身份证号
		
		JSONObject object = API.sendController("benefitNeasuresController.json",param);
		
		if(object.getBoolean("SUCCESS")) {
//			"YLQYLJ":117.72,//月领取养老金
//			"SUMJF":2462.65,//60岁个人账户积累总额
//			"CZBT":30,//年财政补贴
//			"YEARS":15,//缴费时长
//			"GRZHYLJ":17.72,//个人账户养老金
//			"CJDDJ":0//长缴多得增加养老金
			JSONArray o = object.getJSONArray("MSG");
			JSONObject result = o.getJSONObject(0);
			result.put("isPass", true);
			context.getDatas().put("result", result);
		}
	}
	
	public static void main(String[] args) {
		JSONObject param = new JSONObject();
		param.put("AAA121", "QDYCS");
		param.put("STARYEAR", "45");
		param.put("ENDYEAR", "60");
		param.put("AAA041", "100");
		param.put("JCYLJ", "100");
		param.put("AAA031", "0.033");
		param.put("AAC002", "1122"); // 身份证号
		
		JSONObject object = API.sendController("benefitNeasuresController.json",param);
		JSONArray o = object.getJSONArray("MSG");
		JSONObject result = o.getJSONObject(0);
		System.out.println(result);
	}
}
